<template>
  <a-drawer v-model:visible="visible" title="软件详情" :width="width >= 600 ? 600 : '100%'" :footer="false">
    <a-descriptions :column="2" size="large" class="general-description">
      <a-descriptions-item label="ID">{{ dataDetail?.id }}</a-descriptions-item>
      <a-descriptions-item label="名称">{{ dataDetail?.name }}</a-descriptions-item>
      <a-descriptions-item label="备注">{{ dataDetail?.description }}</a-descriptions-item>
      <a-descriptions-item label="类型ID">{{ dataDetail?.categoryId }}</a-descriptions-item>
      <a-descriptions-item label="版本号">{{ dataDetail?.version }}</a-descriptions-item>
      <a-descriptions-item label="供应商ID">{{ dataDetail?.vendorId }}</a-descriptions-item>
      <a-descriptions-item label="SN">{{ dataDetail?.sn }}</a-descriptions-item>
      <a-descriptions-item label="价格">{{ dataDetail?.price }}</a-descriptions-item>
      <a-descriptions-item label="购买日期">{{ dataDetail?.purchaseDate }}</a-descriptions-item>
      <a-descriptions-item label="过保日期">{{ dataDetail?.expireDate }}</a-descriptions-item>
      <a-descriptions-item label="授权数量">{{ dataDetail?.counts }}</a-descriptions-item>
      <a-descriptions-item label="发行方式（0未知，1开源，2免费，3商业授权）">{{ dataDetail?.distribution }}</a-descriptions-item>
      <a-descriptions-item label="状态（1：启用；2：禁用）">{{ dataDetail?.status }}</a-descriptions-item>
      <a-descriptions-item label="创建人">{{ dataDetail?.createUser }}</a-descriptions-item>
      <a-descriptions-item label="创建人">{{ dataDetail?.createUserString }}</a-descriptions-item>
      <a-descriptions-item label="创建时间">{{ dataDetail?.createTime }}</a-descriptions-item>
      <a-descriptions-item label="修改人">{{ dataDetail?.updateUser }}</a-descriptions-item>
      <a-descriptions-item label="修改人">{{ dataDetail?.updateUserString }}</a-descriptions-item>
      <a-descriptions-item label="修改时间">{{ dataDetail?.updateTime }}</a-descriptions-item>
    </a-descriptions>
  </a-drawer>
</template>

<script setup lang="ts">
import { useWindowSize } from '@vueuse/core'
import { type SoftwareRecordsDetailResp, getSoftwareRecords as getDetail } from '@/apis/asset/software/records'
import { useDict } from '@/hooks/app'


const { width } = useWindowSize()

const dataId = ref('')
const dataDetail = ref<SoftwareRecordsDetailResp>()
const visible = ref(false)

// 查询详情
const getDataDetail = async () => {
  const { data } = await getDetail(dataId.value)
  dataDetail.value = data
}

// 打开
const onOpen = async (id: string) => {
  dataId.value = id
  await getDataDetail()
  visible.value = true
}

defineExpose({ onOpen })
</script>

<style scoped lang="scss"></style>
